package com.charm.businesshub

import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import org.jetbrains.anko.*
import org.jetbrains.anko.sdk25.coroutines.onClick
import org.jetbrains.anko.support.v4.UI

/**
 * Created by tools on 2018/1/2.
 */
@Route(path = "/businesshub/main")
class BusinessHubFragment : Fragment() {
    val ID_LOADING = 0x1001
//    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
//        var rootView:View = inflater!!.inflate(R.layout.fragment_hub, container, false)
//        initView(rootView)
//        return rootView
//    }

//    private fun initView(rootView: View) {
//        rootView.findViewById<TextView>(R.id.loading).setOnClickListener {
//            showLoadingDialog()
//        }
//    }

    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return UI {
            relativeLayout {
                padding = 10
                textView("加载框") {
                    id = ID_LOADING
                    padding = dip(10)
                    onClick {
                    }
                }.lparams { horizontalGravity = Gravity.CENTER_HORIZONTAL }
                textView("RecycleView") {
                    gravity = Gravity.CENTER_HORIZONTAL
                    padding = dip(10)
                    onClick {
                        ARouter.getInstance().build("/businesshub/newslist").navigation()
                    }
                }.lparams { below(ID_LOADING) }

            }
        }.view
    }
}